﻿using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using Utils.ModuleKiller;



namespace Server_Management.Event
{
    /// <summary>
    /// 击杀排名板 事件
    /// </summary>
    public class KillLeaderBoradEvent
    {
        [PluginEvent(ServerEventType.WaitingForPlayers)]
        public void OnWaiting(WaitingForPlayersEvent ev)
        {
            KillLeaderboard.Clear();
        }


        [PluginEvent(ServerEventType.PlayerDying)]
        public void OnPlayerDying(PlayerDyingEvent ev)
        {
            if (ev.Player == null) return;
            if (ev.Attacker == null) return;

            if (ev.Player.IsSCP) return;
            if (!ev.Attacker.IsSCP) return;

            switch (ev.Player.Team)
            {
                case PlayerRoles.Team.Scientists:
                case PlayerRoles.Team.FoundationForces:
                    KillLeaderboard.Get(ev.Attacker).KillFoundation++;
                    break;

                case PlayerRoles.Team.ClassD:
                case PlayerRoles.Team.ChaosInsurgency:
                    KillLeaderboard.Get(ev.Attacker).KillChaos++;
                    break;
        
                default:
                    break;
            }
        }


        [PluginEvent(ServerEventType.Scp079GainExperience)]
        public void OnSCP079HelpKill(Scp079GainExperienceEvent ev)
        {
            switch (ev.Reason)
            {
                case PlayerRoles.PlayableScps.Scp079.Scp079HudTranslation.ExpGainBlockingHuman:
                    KillLeaderboard.Get(ev.Player).KillFoundation ++;
                    break;
            }
        }
    }
}
